1. Field of the Invention
The present invention is generally related to program optimization, and more particularly, to a system and method for software recovery mechanism.
2. Description of Related Art
Programming assertions are high-level programming statements that a software engineer can insert into a program to test whether a critical condition failed before executing with the rest of the program code. Failing a test initiated by a program assertion causes the program to abort. The abort is performed because the program assertion causes the branch to code that aborts the program.
When a program aborts, the program generally prints a diagnostic message, which describes the line number in the file that contains the statement that failed the program assertion test. This diagnostic message is generally printed just before the program is aborted.
Typically, programmers expect that a condition that is tested by a program assertion will never fail. Programmers assume that a defect in another portion of the program may produce the condition that causes the programming assertion test to fail. If an error is present, further processing under the failed condition may do great harm to the data, so terminating the program is better than proceeding with the failed condition that harms the data. Another assumption about programming assertions is that once a programming assertion test fails, the program cannot be corrected at the point of the programming assertion. Normally, if the condition could be corrected, the programmer would insert a test for condition followed by correction code instead of inserting a programming insertion into the program.
In general, programming assertions are placed into a program can be enabled and disabled with a single switch. Normally, the programmer enables the programming insertions during the development and testing phase of the program and then disables the programming insertions when the program is released to the consumer. When the programming assertions are disabled, the program promptly ignores any erroneous condition that may cause program errors or data corruption. The programmer disables the assertion to improve the performance of the program. When the programmer does this, the programmer is gambling that the testing with the assertions enabled uncovering of any and all defects that would cause a program assertion to fail. Heretofore, programmers have lacked a system and method for software recovery of a failed program assertion at run time.
The present invention is a system and method for providing a software recovery mechanism. Briefly described, in architecture, the system can be implemented as follows. The preferred system of the present invention utilizes a compiler that parses a source program. Error condition test logic detects if an error condition test exists in the source program, and determination logic determines if error recovery is enabled when the error condition test is detected. Error recovery flag generation logic generates an error recovery flag code when the error condition test is detected and the error recovery is enabled, and error recovery code is inserted in the computer program if error recovery is enabled.
The present invention can also be viewed as providing a method for passing compile time information between a compiler and real-time operation of post-time software. In this regard, the method can be broadly summarized by the following steps: (1) parsing a source program for an error condition test; (2) detecting if an error condition test exists in the source program; (3) determining if error recovery is enabled when the error condition test is detected; (4) creating an error recovery flag code when the error condition test exists and the error recovery is enabled; and (5) inserting error recovery code in the computer program if error recovery is enabled.
Other features and advantages of the present invention will become apparent to one with skill in the art upon examination of the following drawings and detailed description. It is intended that all such additional features and advantages be included herein within the scope of the present invention.